<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Gem::Package - rubygems: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="UserInteraction.html">Gem::UserInteraction</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-build">::build</a>
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-raw_spec">::raw_spec</a>
    <li ><a href="#method-i-add_checksums">#add_checksums</a>
    <li ><a href="#method-i-build">#build</a>
    <li ><a href="#method-i-contents">#contents</a>
    <li ><a href="#method-i-copy_to">#copy_to</a>
    <li ><a href="#method-i-extract_files">#extract_files</a>
    <li ><a href="#method-i-gzip_to">#gzip_to</a>
    <li ><a href="#method-i-initialize">#initialize</a>
    <li ><a href="#method-i-normalize_path">#normalize_path</a>
    <li ><a href="#method-i-read_checksums">#read_checksums</a>
    <li ><a href="#method-i-setup_signer">#setup_signer</a>
    <li ><a href="#method-i-spec">#spec</a>
    <li ><a href="#method-i-verify">#verify</a>
    <li ><a href="#method-i-verify_entry">#verify_entry</a>
    <li ><a href="#method-i-verify_files">#verify_files</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Gem::Package">
    <h1 id="class-Gem::Package" class="class">
      class Gem::Package
    </h1>

    <section class="description">
    
<p>Example using a <a href="Package.html"><code>Gem::Package</code></a></p>

<p>Builds a .gem file given a <a href="Specification.html"><code>Gem::Specification</code></a>. A .gem file is a tarball which contains a data.tar.gz, metadata.gz, checksums.yaml.gz and possibly signatures.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;rubygems&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;rubygems/package&#39;</span>

<span class="ruby-identifier">spec</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">summary</span> = <span class="ruby-string">&quot;Ruby based make-like utility.&quot;</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">name</span> = <span class="ruby-string">&#39;rake&#39;</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">version</span> = <span class="ruby-constant">PKG_VERSION</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">requirements</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;none&#39;</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">files</span> = <span class="ruby-constant">PKG_FILES</span>
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">description</span> = <span class="ruby-identifier">&lt;&lt;-EOF</span>
<span class="ruby-value">Rake is a Make-like program implemented in Ruby. Tasks
and dependencies are specified in standard Ruby syntax.
</span><span class="ruby-identifier">  EOF</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span>.<span class="ruby-identifier">build</span> <span class="ruby-identifier">spec</span>
</pre>

<p>Reads a .gem file.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;rubygems&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;rubygems/package&#39;</span>

<span class="ruby-identifier">the_gem</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path_to_dot_gem</span>)
<span class="ruby-identifier">the_gem</span>.<span class="ruby-identifier">contents</span> <span class="ruby-comment"># get the files in the gem</span>
<span class="ruby-identifier">the_gem</span>.<span class="ruby-identifier">extract_files</span> <span class="ruby-identifier">destination_directory</span> <span class="ruby-comment"># extract the gem into a directory</span>
<span class="ruby-identifier">the_gem</span>.<span class="ruby-identifier">spec</span> <span class="ruby-comment"># get the spec out of the gem</span>
<span class="ruby-identifier">the_gem</span>.<span class="ruby-identifier">verify</span> <span class="ruby-comment"># check the gem is OK (contains valid gem specification, contains a not corrupt contents archive)</span>
</pre>

<p><a href="Package.html#attribute-i-files"><code>files</code></a> are the files in the .gem tar file, not the Ruby files in the gem <a href="Package.html#method-i-extract_files"><code>extract_files</code></a> and <a href="Package.html#method-i-contents"><code>contents</code></a> automatically call <a href="Package.html#method-i-verify"><code>verify</code></a></p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-checksums" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">checksums</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Checksums for the contents of the package</p>
              </div>
            </div>
          <div id="attribute-i-data_mode" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">data_mode</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Permission for other files</p>
              </div>
            </div>
          <div id="attribute-i-dir_mode" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">dir_mode</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Permission for directories</p>
              </div>
            </div>
          <div id="attribute-i-files" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">files</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The files in this package.  This is not the contents of the gem, just the files in the top-level container.</p>
              </div>
            </div>
          <div id="attribute-i-gem" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">gem</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Reference to the gem being packaged.</p>
              </div>
            </div>
          <div id="attribute-i-prog_mode" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">prog_mode</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Permission for program files</p>
              </div>
            </div>
          <div id="attribute-i-security_policy" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">security_policy</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>The security policy used for verifying the contents of this package.</p>
              </div>
            </div>
          <div id="attribute-i-spec" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">spec</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Sets the <a href="Specification.html"><code>Gem::Specification</code></a> to use to build this package.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-build" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build</span><span
                                class="method-args">(spec, skip_validation = false, strict_validation = false, file_name = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 132</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">build</span>(<span class="ruby-identifier">spec</span>, <span class="ruby-identifier">skip_validation</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">strict_validation</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">file_name</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">gem_file</span> = <span class="ruby-identifier">file_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">spec</span>.<span class="ruby-identifier">file_name</span>

  <span class="ruby-identifier">package</span> = <span class="ruby-identifier">new</span> <span class="ruby-identifier">gem_file</span>
  <span class="ruby-identifier">package</span>.<span class="ruby-identifier">spec</span> = <span class="ruby-identifier">spec</span>
  <span class="ruby-identifier">package</span>.<span class="ruby-identifier">build</span> <span class="ruby-identifier">skip_validation</span>, <span class="ruby-identifier">strict_validation</span>

  <span class="ruby-identifier">gem_file</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(gem, security_policy = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="Package.html"><code>Gem::Package</code></a> for the file at <code>gem</code>. <code>gem</code> can also be provided as an IO object.</p>

<p>If <code>gem</code> is an existing file in the old format a <a href="Package/Old.html"><code>Gem::Package::Old</code></a> will be returned.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 149</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">new</span>(<span class="ruby-identifier">gem</span>, <span class="ruby-identifier">security_policy</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">gem</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">Source</span>)
    <span class="ruby-identifier">gem</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value">:read</span>
    <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">IOSource</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">gem</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FileSource</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">gem</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">super</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">super</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">present?</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">super</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">start</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">super</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">start</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;MD5SUM =&quot;</span>

  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">Old</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">gem</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-raw_spec" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">raw_spec</span><span
                                class="method-args">(path, security_policy = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extracts the <a href="Specification.html"><code>Gem::Specification</code></a> and raw metadata from the .gem file at <code>path</code>.</p>

                              <div class="method-source-code" id="raw_spec-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 172</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">raw_spec</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">security_policy</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">format</span> = <span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">security_policy</span>)
  <span class="ruby-identifier">spec</span> = <span class="ruby-identifier">format</span>.<span class="ruby-identifier">spec</span>

  <span class="ruby-identifier">metadata</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span> <span class="ruby-identifier">path</span>, <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">binary_mode</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">tar</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarReader</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">io</span>
    <span class="ruby-identifier">tar</span>.<span class="ruby-identifier">each_entry</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">full_name</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;metadata&quot;</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">metadata</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">read</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;metadata.gz&quot;</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">metadata</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">gunzip</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">read</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  [<span class="ruby-identifier">spec</span>, <span class="ruby-identifier">metadata</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_checksums" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_checksums</span><span
                                class="method-args">(tar)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds a checksum for each entry in the gem to checksums.yaml.gz.</p>

                              <div class="method-source-code" id="add_checksums-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 222</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_checksums</span>(<span class="ruby-identifier">tar</span>)
  <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">load_yaml</span>

  <span class="ruby-identifier">checksums_by_algorithm</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">algorithm</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">algorithm</span>] = {} }

  <span class="ruby-ivar">@checksums</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">digests</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">digests</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">digest</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">checksums_by_algorithm</span>[<span class="ruby-identifier">algorithm</span>][<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">digest</span>.<span class="ruby-identifier">hexdigest</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">tar</span>.<span class="ruby-identifier">add_file_signed</span> <span class="ruby-string">&quot;checksums.yaml.gz&quot;</span>, <span class="ruby-value">0o444</span>, <span class="ruby-ivar">@signer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">gzip_to</span> <span class="ruby-identifier">io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gz_io</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">Psych</span>.<span class="ruby-identifier">dump</span> <span class="ruby-identifier">checksums_by_algorithm</span>, <span class="ruby-identifier">gz_io</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build</span><span
                                class="method-args">(skip_validation = false, strict_validation = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds this package based on the specification set by <a href="Package.html#attribute-i-spec"><code>spec=</code></a></p>

                              <div class="method-source-code" id="build-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 293</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build</span>(<span class="ruby-identifier">skip_validation</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">strict_validation</span> = <span class="ruby-keyword">false</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;skip_validation = true and strict_validation = true are incompatible&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">skip_validation</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">strict_validation</span>

    <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">load_yaml</span>

    <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">mark_version</span>
    <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">validate</span> <span class="ruby-keyword">true</span>, <span class="ruby-identifier">strict_validation</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">skip_validation</span>

    <span class="ruby-identifier">setup_signer</span>(
      <span class="ruby-value">signer_options:</span> {
        <span class="ruby-value">expiration_length_days:</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">cert_expiration_length_days</span>,
      }
    )

    <span class="ruby-ivar">@gem</span>.<span class="ruby-identifier">with_write_io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gem_io</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarWriter</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">gem_io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gem</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">add_metadata</span> <span class="ruby-identifier">gem</span>
        <span class="ruby-identifier">add_contents</span> <span class="ruby-identifier">gem</span>
        <span class="ruby-identifier">add_checksums</span> <span class="ruby-identifier">gem</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">say</span> <span class="ruby-identifier">&lt;&lt;-EOM</span>
<span class="ruby-value">  Successfully built RubyGem
  Name: #{@spec.name}
  Version: #{@spec.version}
  File: #{File.basename @gem.path}
</span><span class="ruby-identifier">EOM</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@signer</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-contents" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">contents</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>A list of file names contained in this gem</p>

                              <div class="method-source-code" id="contents-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">contents</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@contents</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@contents</span>

  <span class="ruby-identifier">verify</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@spec</span>

  <span class="ruby-ivar">@contents</span> = []

  <span class="ruby-ivar">@gem</span>.<span class="ruby-identifier">with_read_io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">gem_tar</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarReader</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">io</span>

    <span class="ruby-identifier">gem_tar</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">full_name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;data.tar.gz&quot;</span>

      <span class="ruby-identifier">open_tar_gz</span> <span class="ruby-identifier">entry</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pkg_tar</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">pkg_tar</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">contents_entry</span><span class="ruby-operator">|</span>
          <span class="ruby-ivar">@contents</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">contents_entry</span>.<span class="ruby-identifier">full_name</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">return</span> <span class="ruby-ivar">@contents</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipFile</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>, <span class="ruby-constant">EOFError</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarInvalidError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-ivar">@gem</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy_to" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_to</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies this package to <code>path</code> (if possible)</p>

                              <div class="method-source-code" id="copy_to-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 215</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_to</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span> <span class="ruby-ivar">@gem</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">path</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">path</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-extract_files" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">extract_files</span><span
                                class="method-args">(destination_dir, pattern = &quot;*&quot;)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extracts the files in this package into <code>destination_dir</code></p>

<p>If <code>pattern</code> is specified, only entries matching that glob will be extracted.</p>

                              <div class="method-source-code" id="extract_files-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 384</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">extract_files</span>(<span class="ruby-identifier">destination_dir</span>, <span class="ruby-identifier">pattern</span> = <span class="ruby-string">&quot;*&quot;</span>)
  <span class="ruby-identifier">verify</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@spec</span>

  <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">destination_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">dir_mode</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-value">0o755</span>

  <span class="ruby-ivar">@gem</span>.<span class="ruby-identifier">with_read_io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">reader</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarReader</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">io</span>

    <span class="ruby-identifier">reader</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">full_name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;data.tar.gz&quot;</span>

      <span class="ruby-identifier">extract_tar_gz</span> <span class="ruby-identifier">entry</span>, <span class="ruby-identifier">destination_dir</span>, <span class="ruby-identifier">pattern</span>

      <span class="ruby-keyword">break</span> <span class="ruby-comment"># ignore further entries</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipFile</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>, <span class="ruby-constant">EOFError</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarInvalidError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-ivar">@gem</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-gzip_to" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">gzip_to</span><span
                                class="method-args">(io) { |gz_io| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gzips content written to <code>gz_io</code> to <code>io</code>.</p>

                              <div class="method-source-code" id="gzip_to-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 491</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">gzip_to</span>(<span class="ruby-identifier">io</span>) <span class="ruby-comment"># :yields: gz_io</span>
  <span class="ruby-identifier">gz_io</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">io</span>, <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">BEST_COMPRESSION</span>
  <span class="ruby-identifier">gz_io</span>.<span class="ruby-identifier">mtime</span> = <span class="ruby-ivar">@build_time</span>

  <span class="ruby-keyword">yield</span> <span class="ruby-identifier">gz_io</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-identifier">gz_io</span>.<span class="ruby-identifier">close</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-normalize_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize_path</span><span
                                class="method-args">(pathname)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="normalize_path-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 519</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize_path</span>(<span class="ruby-identifier">pathname</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">win_platform?</span>
    <span class="ruby-identifier">pathname</span>.<span class="ruby-identifier">downcase</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">pathname</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_checksums" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_checksums</span><span
                                class="method-args">(gem)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads and loads checksums.yaml.gz from the tar file <code>gem</code></p>

                              <div class="method-source-code" id="read_checksums-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 555</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_checksums</span>(<span class="ruby-identifier">gem</span>)
  <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">load_yaml</span>

  <span class="ruby-ivar">@checksums</span> = <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">seek</span> <span class="ruby-string">&quot;checksums.yaml.gz&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipReader</span>.<span class="ruby-identifier">wrap</span> <span class="ruby-identifier">entry</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gz_io</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">SafeYAML</span>.<span class="ruby-identifier">safe_load</span> <span class="ruby-identifier">gz_io</span>.<span class="ruby-identifier">read</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-setup_signer" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">setup_signer</span><span
                                class="method-args">(signer_options: {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Prepares the gem for signing and checksum generation.  If a signing certificate and key are not present only checksum generation is set up.</p>

                              <div class="method-source-code" id="setup_signer-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 569</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setup_signer</span>(<span class="ruby-value">signer_options:</span> {})
  <span class="ruby-identifier">passphrase</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">&quot;GEM_PRIVATE_KEY_PASSPHRASE&quot;</span>]
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">signing_key</span>
    <span class="ruby-ivar">@signer</span> =
      <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span><span class="ruby-operator">::</span><span class="ruby-constant">Signer</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">signing_key</span>,
        <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">cert_chain</span>,
        <span class="ruby-identifier">passphrase</span>,
        <span class="ruby-identifier">signer_options</span>
      )

    <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">signing_key</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">cert_chain</span> = <span class="ruby-ivar">@signer</span>.<span class="ruby-identifier">cert_chain</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_s</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@signer</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span><span class="ruby-operator">::</span><span class="ruby-constant">Signer</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">passphrase</span>
    <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">cert_chain</span> = <span class="ruby-ivar">@signer</span>.<span class="ruby-identifier">cert_chain</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_pem</span>) <span class="ruby-keyword">if</span>
      <span class="ruby-ivar">@signer</span>.<span class="ruby-identifier">cert_chain</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-spec" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">spec</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The spec for this gem.</p>

<p>If this is a package for a built gem the spec is loaded from the gem and returned.  If this is a package for a gem being built the provided spec is returned.</p>

                              <div class="method-source-code" id="spec-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 596</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">spec</span>
  <span class="ruby-identifier">verify</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@spec</span>

  <span class="ruby-ivar">@spec</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">verify</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verifies that this gem:</p>
<ul><li>
<p>Contains a valid gem specification</p>
</li><li>
<p>Contains a contents archive</p>
</li><li>
<p>The contents archive is not corrupt</p>
</li></ul>

<p>After verification the gem specification from the gem is available from <a href="Package.html#method-i-spec"><code>spec</code></a></p>

                              <div class="method-source-code" id="verify-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 612</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">verify</span>
  <span class="ruby-ivar">@files</span>     = []
  <span class="ruby-ivar">@spec</span>      = <span class="ruby-keyword">nil</span>

  <span class="ruby-ivar">@gem</span>.<span class="ruby-identifier">with_read_io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarReader</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">io</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">reader</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">read_checksums</span> <span class="ruby-identifier">reader</span>

      <span class="ruby-identifier">verify_files</span> <span class="ruby-identifier">reader</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">verify_checksums</span> <span class="ruby-ivar">@digests</span>, <span class="ruby-ivar">@checksums</span>

  <span class="ruby-ivar">@security_policy</span>&amp;.<span class="ruby-identifier">verify_signatures</span> <span class="ruby-ivar">@spec</span>, <span class="ruby-ivar">@digests</span>, <span class="ruby-ivar">@signatures</span>

  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span><span class="ruby-operator">::</span><span class="ruby-constant">Exception</span>
  <span class="ruby-ivar">@spec</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@files</span> = []
  <span class="ruby-identifier">raise</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipFile</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>, <span class="ruby-constant">EOFError</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">TarInvalidError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-ivar">@gem</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">verify_entry</span><span
                                class="method-args">(entry)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verifies <code>entry</code> in a .gem file.</p>

                              <div class="method-source-code" id="verify_entry-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 661</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">verify_entry</span>(<span class="ruby-identifier">entry</span>)
  <span class="ruby-identifier">file_name</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">full_name</span>
  <span class="ruby-ivar">@files</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">file_name</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">file_name</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\.sig$/</span> <span class="ruby-keyword">then</span>
    <span class="ruby-ivar">@signatures</span>[<span class="ruby-node">$`</span>] = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">read</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@security_policy</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">digest</span> <span class="ruby-identifier">entry</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">file_name</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;metadata&quot;</span>, <span class="ruby-string">&quot;metadata.gz&quot;</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">load_spec</span> <span class="ruby-identifier">entry</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;data.tar.gz&quot;</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">verify_gz</span> <span class="ruby-identifier">entry</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span>
  <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Exception while verifying #{@gem.path}&quot;</span>
  <span class="ruby-identifier">raise</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify_files" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">verify_files</span><span
                                class="method-args">(gem)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verifies the files of the <code>gem</code></p>

                              <div class="method-source-code" id="verify_files-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 687</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">verify_files</span>(<span class="ruby-identifier">gem</span>)
  <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">verify_entry</span> <span class="ruby-identifier">entry</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@spec</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> <span class="ruby-string">&quot;package metadata is missing&quot;</span>, <span class="ruby-ivar">@gem</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;data.tar.gz&quot;</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span><span class="ruby-operator">::</span><span class="ruby-constant">FormatError</span>.<span class="ruby-identifier">new</span> \
      <span class="ruby-string">&quot;package content (data.tar.gz) is missing&quot;</span>, <span class="ruby-ivar">@gem</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">duplicates</span> = <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">group_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span> }.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">_k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span> }.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:first</span>)) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">duplicates</span>.<span class="ruby-identifier">any?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Security</span><span class="ruby-operator">::</span><span class="ruby-constant">Exception</span>, <span class="ruby-node">&quot;duplicate files in the package: (#{duplicates.map(&amp;:inspect).join(&quot;, &quot;)})&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="protected-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Protected Instance Methods</h3>
                </header>

                  <div id="method-i-initialize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize</span><span
                                class="method-args">(gem, security_policy)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new package that will read or write to the file <code>gem</code>.</p>

                              <div class="method-source-code" id="initialize-source">
            <pre><span class="ruby-comment"># File rubygems/package.rb, line 196</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">gem</span>, <span class="ruby-identifier">security_policy</span>) <span class="ruby-comment"># :notnew:</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;zlib&quot;</span>

  <span class="ruby-ivar">@gem</span> = <span class="ruby-identifier">gem</span>

  <span class="ruby-ivar">@build_time</span>      = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">source_date_epoch</span>
  <span class="ruby-ivar">@checksums</span>       = {}
  <span class="ruby-ivar">@contents</span>        = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@digests</span>         = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">algorithm</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">algorithm</span>] = {} }
  <span class="ruby-ivar">@files</span>           = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@security_policy</span> = <span class="ruby-identifier">security_policy</span>
  <span class="ruby-ivar">@signatures</span>      = {}
  <span class="ruby-ivar">@signer</span>          = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@spec</span>            = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

